setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "ERROR : ".$e->getMessage(); } $term=$_GET["term"]; $stmt = $DBcon->prepare("SELECT * FROM students_info where fullname like '%".$term."%' order by fullname"); $stmt->execute(); $json=array(); while($row=$stmt->FETCH(PDO::FETCH_ASSOC)) { $json[]=array( 'value'=> $row["regno"], 'label'=>$row["fullname"]." - ".$row["regno"] ); } echo json_encode($json); ?>